unit FormPesquisaSolicitanteParametroUnit;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, JvExDBGrids,
  JvDBGrid, Vcl.StdCtrls, System.Actions, Vcl.ActnList;

type
  TFormPesquisaSolicitanteParametro = class(TForm)
    Label1: TLabel;
    EditPesquisar: TEdit;
    JvDBGrid1: TJvDBGrid;
    ActionList1: TActionList;
    Actionesc: TAction;
    procedure JvDBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ActionescExecute(Sender: TObject);
    procedure EditPesquisarChange(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure JvDBGrid1DblClick(Sender: TObject);
    procedure EditPesquisarKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    idsolicitante : integer;
    nomesolicitante : string;
  end;

var
  FormPesquisaSolicitanteParametro: TFormPesquisaSolicitanteParametro;

implementation

{$R *.dfm}

uses DMDadosUnt;

procedure TFormPesquisaSolicitanteParametro.ActionescExecute(Sender: TObject);
begin
  idsolicitante   := 0;
  nomesolicitante := '';
  Close;
end;

procedure TFormPesquisaSolicitanteParametro.EditPesquisarChange(
  Sender: TObject);
begin
  DMDados.dsSolicitanteP.DataSet.Filtered := false;

  DMDados.dsSolicitanteP.DataSet.Filter := 'NOME_SOLICITANTE LIKE '+QuotedStr('%'+EditPesquisar.Text+'%');


  DMDados.dsSolicitanteP.DataSet.Filtered := true;
end;

procedure TFormPesquisaSolicitanteParametro.EditPesquisarKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if key = VK_DOWN then
begin
  JvDBGrid1.SetFocus;
end;
if key = VK_RETURN then
begin
  JvDBGrid1.SetFocus;
end;
end;

procedure TFormPesquisaSolicitanteParametro.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  DMDados.dsSolicitanteP.DataSet.Filtered := false;
end;

procedure TFormPesquisaSolicitanteParametro.JvDBGrid1DblClick(Sender: TObject);
begin
    idsolicitante   := DMDados.cdsSolicitantePID_SOLICITANTE.AsInteger;
    nomesolicitante := DMDados.cdsSolicitantePNOME_SOLICITANTE.AsString;
    close;
end;

procedure TFormPesquisaSolicitanteParametro.JvDBGrid1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key = VK_RETURN then
  begin
    idsolicitante   := DMDados.cdsSolicitantePID_SOLICITANTE.AsInteger;
    nomesolicitante := DMDados.cdsSolicitantePNOME_SOLICITANTE.AsString;
    close;
  end;
end;

end.
